#include <core/synced_current_mission.h>
#include <boost/thread/locks.hpp>

using boost::unique_lock;

SyncedCurrentMission::SyncedCurrentMission() : accomplished_(true) {};

bool SyncedCurrentMission::accomplished() {
  unique_lock<mutex> lock(mutex_);
  return accomplished_;
}

void SyncedCurrentMission::set_accomplished(bool accomplished) {
  unique_lock<mutex> lock(mutex_);
  accomplished_ = accomplished;
}

void SyncedCurrentMission::set_current_mission(const player_pose2d &current_mission) {
  unique_lock<mutex> lock(mutex_);
  current_mission_ = current_mission;
  accomplished_ = false;
}

player_pose2d SyncedCurrentMission::current_mission() {
  unique_lock<mutex> lock(mutex_);
  return current_mission_;
}

player_point_2d SyncedCurrentMission::current_mission_position() {
  unique_lock<mutex> lock(mutex_);
  player_point_2d current_position;
  current_position.px = current_mission_.px;
  current_position.py = current_mission_.py;
  return current_position;
}
